﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FantastPlatform.Community.IService;
using FantastPlatform.Framework;
using FantastPlatform.Framework.Core;
using FantastPlatform.Community.IMode;
using FantastPlatform.Framework.Model;
using FantastPlatform.Framework.IModel;

namespace FantastPlatform.Community.UI.SocietalForces
{
    public partial class SocietalForcesTypePanel : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ISocietalForcesTypeService sfService = ServiceFactory.CreateService<ISocietalForcesTypeService>();
            ConditionGroup group = new ConditionGroup();
            Condition enableCondition = new Condition() { Type = typeof(bool).FullName, Field = "Enable", Value1 = true };
            group.Conditions.Add(enableCondition);
            IList<Sort> sorts = new List<Sort>();
            sorts.Add(new Sort() { Field = "CreateDate", Order = Orders.Asc });
            int total = 0;
            switch (Action) 
            {
                case "Load":
                    IList<ISocietalForcesType> sftList = sfService.Search(group, sorts, int.MaxValue, 0, out total);
                    if (sftList.Count > 0) 
                    {
                        ReturnList(total, sftList);
                    }
                    break;
                default:
                    break;
            }
        }
    }
}